#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=1010;
int n,q;
signed main(){
	freopen("replace.in","r",stdin);
	freopen("replace.out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin>>n>>q;
	for(int i=1;i<=n;i++){
		string s,t;
		cin>>s>>t;
	}
	while(q--){
		string s,t;
		cin>>s>>t;
		cout<<"0\n";
	}
	return 0;
}
